﻿#region Using Directives

    using System;

    using MarketPulse.BusinessLogic.Common;

#endregion

namespace MarketPulse.BusinessLogic.Private.StateMachine
{
    [Serializable]
    internal class AssignmentStateDataEntryInProgress : AssignmentStateBase
    {
        internal AssignmentStateDataEntryInProgress(bool throwIfInvalid) : base(throwIfInvalid)
        {
            mAssignmentStateType = AssignmentStatusTypeList.DataEntryInProgress;
            InitAssignmentStateString();
        }

        public override bool StartDataEntry(IAssignmentStateContext context, bool tryTransition)
        {
            // Do nothing probably, but this is a valid transition
            return true;
        }

        public override bool DataEnter(IAssignmentStateContext context, bool tryTransition, System.Xml.Linq.XElement responses)
        {
            // Do nothing probably, but this is a valid transition
            return true;
        }

        public override bool CompleteDataEntry(IAssignmentStateContext context, bool tryTransition)
        {
            if (!tryTransition)
            {
                context.SetState(new AssignmentStateAwaitingQA(mThrowIfInvalid));
            }
            return true;
        }

        //public override bool Unassign(IAssignmentStateContext context, bool tryTransition, Assignment.PaymentStatus payment)
        //{
        //    if (!tryTransition)
        //    {
        //        context.SetState(new AssignmentStateReleased(mThrowIfInvalid));
        //    }
        //    return true;
        //}

        public override bool Revisit(IAssignmentStateContext context, bool tryTransition)
        {
            if (!tryTransition)
            {
                context.SetState(new AssignmentStateReleased(mThrowIfInvalid));
            }
            return true;
        }
    }
}
